
package projForWen;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JSeparator;

/**
 * 状态栏
 *
 * @author monitor
 * Created on 2011-1-4, 23:49:33
 */
public class StatusBar extends JPanel{

    public StatusBar(){
        initComponents();
    }
    
    private void initComponents(){
        JPanel part1,part2;
        setLayout(new java.awt.GridLayout());
        part1=new JPanel();
        part1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
        tipLabel=new JLabel("加载信息");
        part1.add(tipLabel);
        add(part1);
        part2=new JPanel();
        part2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        msgLabel=new JLabel("MirrorTool(run)");
        part2.add(msgLabel);
        bar=new JProgressBar();
        part2.add(bar);
        separator1=new JSeparator();
        separator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        part2.add(separator1);
        xLabel=new JLabel("");
        part2.add(xLabel);
        yLabel=new JLabel("");
        part2.add(yLabel);
        endLabel=new JLabel("INS");
        part2.add(endLabel);
        add(part2);
        barHide();
        //this.setSize(this.getWidth(), 50);
    }

    public void barHide(){
        msgLabel.setText(null);
        bar.setVisible(false);
    }
    public void barShow(){
        bar.setVisible(true);
        bar.setIndeterminate(true);
    }
    public void setBarMsg(String msg){
        msgLabel.setText(msg);
    }
    public void setBarInfo(String msg){
        tipLabel.setText(msg);
    }
    public void setBarIndeterminate(boolean flag){
        bar.setIndeterminate(flag);
    }
    public void setBarValue(int value){
        bar.setValue(value);
    }
    public void setBarMaximum(int max){
        bar.setMaximum(max);
    }
    public void setXMsg(String msg){
        xLabel.setText(msg);
    }
    public void setYMsg(String msg){
        yLabel.setText(msg);
    }
    private static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = MainUI.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
    private JProgressBar bar;
    private JLabel tipLabel;
    private JLabel msgLabel;
    private JLabel endLabel;
    private JLabel xLabel;
    private JLabel yLabel;
    private JSeparator separator1;

}
